package com.xh.common;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * Created by xuhe on 2017/11/8.
 */
@Configuration
@EnableWebMvc
@EnableSwagger2
public class Swagger2Config extends WebMvcConfigurerAdapter {
    @Bean
    public Docket getApiInfo() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(outApiInfo())
                .groupName("outer api")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.xh"))
                .paths(PathSelectors.any())
                .build();

    }

    private ApiInfo outApiInfo() {
        return new ApiInfoBuilder()
                .title( "RESTful APIs" )
                .description( "api接口文档" )
                .contact( new Contact( "powervotex", "", "" ) )
                .version( "1.0" )
                .build();
    }

}
